const dgram = require('dgram');
const server = dgram.createSocket('udp4');

server.bind(41235,'localhost');
server.on('message',(msg,rinfo) => {
    console.log('%s',msg)
    server.send('我收到了',rinfo.port,rinfo.address);

    /**
     * 广播给所有人
     * server.setBroadcast(true);
     * let addary = rinfo.address.split(.);
     * addary[3] = 255;
     * server.send('我收到了',rinfo.port,addary.join('.'));
     */
})

